<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
	#div1 { width: 200px; height: 200px; position: absolute; background: red;}	
</style>
<script>
	
window.onload = function()
{
		
		var oBtn = document.getElementById('btn1');
		var oDiv1 = document.getElementById('div1');
	
		oBtn.onclick = function(){StartMove();};
	
	function StartMove()
	{
			var timer =null;
			timer =setInterval(function()
																					{ 
																							oDiv1.style.left = oDiv1.offsetLeft + 10 + 'px';
																							if(oDiv1.offsetLeft>=300)
																							{
																									clearInterval(timer);
																							}
																					},
																					50);
	}
};
</script>
</head>

<body>
<input type="button" id="btn1" value="运动">
<div id="div1"></div>
</body>
</html>
